/*
 * @Author: fisher
 * @Date: 2024-02-28 11:12:48
 * @LastEditors: fisher luthor-li@qq.com
 * @LastEditTime: 2024-02-28 11:13:29
 * @FilePath: \allback\utils\common.js
 * @Description:
 */
exports.generateId = (prefix = '', length = 9) => {
  // 创建一个足够长的随机字符串
  let randomChars = ''
  while (randomChars.length < length) {
    // 添加随机字符，直到我们获得所需长度的字符串
    randomChars += Math.random().toString(36).substr(2)
  }
  // 剪切字符串以确保它的长度不会超过所需长度
  randomChars = randomChars.substr(0, length)

  // 返回前缀和随机字符
  return `${prefix}${randomChars}`
}
